<include file="Public:header"/>
<div class="cat" style="margin-top:5px;">
<h2>【{$prop}】</h2>
<form method="POST" action="__URL__/add">
<table border="0" width="400px;" style="border-collapse: collapse; border: 1px solid #CCCCCC; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px">
	<tr>
		<td align="right"></td>
		<td align="left"><input type="text" name="prop_name" size="20" value="{$prop}" style="display:none"></td>
	</tr>
	<tr>
		<td align="right" valign="top">规格值：</td>
		<td align="left"><textarea rows="5" name="prop_value" cols="20"></textarea></td>
	</tr>
	<tr>
		<td colspan="2" align="center"><input type="submit" value="添加新规格值" name="B1"></td>
	</tr>
</table>
</form>
</div>

<div class="cat" style="margin-top:10px;">
<table bordercolor="#DDDFFF" border="1" width="100%" style="border-collapse: collapse" cellpadding="3">
	<tr height="17" align="center">
		<td class="title" width="300">规格名称</td>
		<td class="title" width="40">删除</td>
		<td class="title">　</td>
	</tr>
<volist name="prop_value" id="prop_value">
	<tr height="20" bgcolor="#F1F5FA" class="cat_list">
		<td width="300">
		<input type="text" name="prop_id[]" value="{$prop_value.prop_id}" style="display:none">
		<input type="text" name="prop_value[]" value="{$prop_value.prop_value}">
		</td>
		<td width="40" align="center"><img onclick="del('{$prop_value.prop_id}')" alt="删除" src="__APP__/statics/icons/icon_delete.gif"></td>

		<td></td>
	</tr>
</volist>
</table>
</div>
<div id="save"><input id="save_m" type="button" value="保存更改"></div>

<script>
$(function(){
    $("#save_m").click(function(){
              var prop_id=[];
			  $("[name='prop_id[]']").each(function(){
                     prop_id.push($(this).val()); 
               }); 
			   var prop_value=[];
			  $("[name='prop_value[]']").each(function(){
                     prop_value.push($(this).val()); 
               }); 
			   $.ajax({
			         type:"POST",
					 url:"__URL__/save_edit",
					 dataType:"html",
					 data:{'prop_id':prop_id,'prop_value':prop_value},
					 success:function(data){
					 
						location.reload();
					 }
			   })
	})
})


function del(t){
    var id=t;//这里删除的标准是@规格名@不是id
	if(confirm('你确认删除此规格吗？')) {
		$.ajax({
			 type:"GET",
			 url:"__URL__/del_value",
			 dataType:"json",
			 data:{'id':id},
			 success:function(data){
				if(data=='0'){
					jError("<strong>删除失败!</strong>",{VerticalPosition : 'center',HorizontalPosition : 'center'});
				}else{
					jSuccess("<strong>删除成功！</strong>",{VerticalPosition : 'center',HorizontalPosition : 'center',onClosed:function(){location.reload();}});
				}
			 }
		})
	}
}
</script>